<template>
	<view class="detect">
		<uni-table border stripe emptyText="暂无更多数据">
			<!-- 表头行 -->
			<uni-tr>
				<uni-th align="center">检测时间</uni-th>
				<uni-th align="center">检测结果</uni-th>
			</uni-tr>
			<!-- 表格数据行 -->
			<uni-tr v-for="item,index in Data" :key="index">
				<uni-td align="center">{{item.DetectionTime}}</uni-td>
				<uni-td align="center">{{item.DetectionResult}}</uni-td>
			</uni-tr>

		</uni-table>
		<view class="bottom" v-if="bottomShow">
			没有更多数据了~
		</view>
	</view>
</template>

<script>
	import {
		GetMacDirectionByPhone
	} from '../../utils/api.js';
	import {
		Base64
	} from '../../utils/base64_2.js';
	export default {
		data() {
			return {
				info: {
					Page: 25,
					Limit: 1,
					beginTime: null,
					endTime: null,
					phone: ''
				},
				Data: [],
				bottomShow: false,
				isNone: false
			}
		},
		onLoad() {
			this.GetMacDirectionByPhone()
		},
		onReachBottom() {
			console.log("onReachBottom");
			if(this.isNone){
				
			}else{
				this.info.Limit ++
				this.GetMacDirectionByPhone()
			}
			
		},
		methods: {
			GetMacDirectionByPhone() {
				let base64 = new Base64()
				//加密base64.encode	
				this.info.phone = base64.encode(this.$store.state.vx_u_info.Phone.toString())
				// console.log(phone);
				GetMacDirectionByPhone(this.info).then((res) => {
					console.log(res);
					if(res.Data.length){
						this.Data = this.Data.concat(res.Data)
						this.Data.forEach((item) => {
							if (item.DetectionResult == '0') {
								item.DetectionResult = '阴性'
							}
							if (item.DetectionResult == '1') {
								item.DetectionResult = '阳性'
							}
							if (item.DetectionResult == '2') {
								item.DetectionResult = '无效'
							}
							if (item.DetectionResult == '3') {
								item.DetectionResult = '检测未完成'
							}
						})
					}else{
						this.bottomShow = true
						this.isNone = true
					}
					
				})
			},

		}
	}
</script>

<style lang="scss" scoped>

	::v-deep .uni-table{
		.uni-table-th,
		    .uni-table-th-content {
		        color: #2989d1;
		        font-size: 32rpx;
		        font-weight: normal;
		    }
		
		    // 改表内容字体样式
		    .uni-table-td {
		        color: #0d070a;
		        font-size: 30rpx;
		    }
	}
	.bottom{
		margin-top: 20rpx;
		text-align: center;
		font-size: 24rpx;
		color: #666666;
	}
	
</style>